#include<iostream>
#include<map>

using namespace std;

map<int, int> mp;

int main(void) {
	int n, num, ans1, ans2;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> num;
		mp[num]++;
	}
	ans2 = 0;
	for(map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
		if((it->second) >= ans2) {
			ans2 = it->second;
			ans1 = it->first;
		} 
	}
	cout << ans1 << ends << ans2 << endl;
	return 0;
}
